<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['insurance:repordRecord:add']"-->
<!--        >新增</el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['insurance:repordRecord:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['insurance:repordRecord:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['insurance:repordRecord:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table  v-loading="loading" :data="repordRecordList"  @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!--      <el-table-column label="主键" align="center" prop="id" />-->
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="实际用工单位" align="center" prop="actualUnit" />
      <el-table-column label="劳动合同单位" align="center" prop="laborUnit" />
      <el-table-column label="业务来源单位" align="center" prop="businessUnit" />
      <el-table-column label="事故发生时间" align="center" prop="accidentTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.accidentTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="工种" align="center" prop="industryId" />-->
      <el-table-column label="事情经过" align="center" prop="description" />
      <el-table-column label="工种名称" align="center" prop="industryName" />
      <el-table-column label="预估金额，单位" align="center" prop="estimateMoney" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="更新时间" align="center" prop="updateTime" />
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-claim"
            @click="handDetails(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-upload2"
            @click="handeImage(scope.row)"
            v-if="scope.row.status=='0' "
          >资料上传</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['insurance:repordRecord:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateImage(scope.row)"
            v-hasPermi="['insurance:repordRecord:edit']"
            v-if="scope.row.status!='0' "
          >修改资料</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['insurance:repordRecord:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改报案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" readonly />
        </el-form-item>
        <el-form-item label="实际用工单位" prop="actualUnit">
          <el-input v-model="form.actualUnit" placeholder="请输入实际用工单位"  />
        </el-form-item>
        <el-form-item label="劳动合同单位" prop="laborUnit">
          <el-input v-model="form.laborUnit" placeholder="请输入劳动合同单位" readonly />
        </el-form-item>
        <el-form-item label="业务来源单位" prop="businessUnit">
          <el-input v-model="form.businessUnit" placeholder="请输入业务来源单位" readonly />
        </el-form-item>
        <el-form-item label="事故发生时间" prop="accidentTime">
          <el-date-picker clearable size="small"
                          v-model="form.accidentTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择事故发生时间">
          </el-date-picker>
        </el-form-item>
<!--        <el-form-item label="工种" prop="industryId">-->
<!--          <el-input v-model="form.industryId" placeholder="请输入工种" />-->
<!--        </el-form-item>-->
        <el-form-item label="事情经过" prop="description">
          <el-input v-model="form.description" type="textarea"  placeholder="请输入事情经过" />
        </el-form-item>
        <el-form-item label="工种名称" prop="industryId">
          <treeselect style="width: 250px" v-model="form.industryId" @select="selectDepart" :options="industryOptions"
                      :normalizer="normalizer" placeholder="请选上级分类"/>
        </el-form-item>
        <el-form-item label="预估金额，单位" prop="estimateMoney">
          <el-input v-model="form.estimateMoney" placeholder="请输入预估金额，单位" />
        </el-form-item>
        <el-form-item label="证件号码" prop="estimateMoney">
          <el-input v-model="form.idCardNo" placeholder="请输入证件号码" readonly />
        </el-form-item>
        <el-form-item label="备注" prop="estimateMoney">
          <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="title1" :visible.sync="open1" width="1000px" append-to-body>
      <el-form ref="form" :model="form1" :rules="rules1" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="身份证" prop="idCard" ref="uploadElement">
              <div v-if="show"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9" @click="getidCard">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9" ></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard" >
                <img v-for="(item,index) in form1.idCard" style="margin-right: 5px;margin-bottom: 5px"  :src="url+item" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="住院小结" prop="hospitalized">
              <div v-if="show1"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9"  @click="getidCard1">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard1">
                <img  v-for="(item,index) in form1.hospitalized" :src="url+item" style="margin-right: 5px;margin-bottom: 5px" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>

        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="病历本" prop="medicalHistory">
              <div v-if="show2"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9"  @click="getidCard2">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard2">
                <img v-for="(item,index) in form1.medicalHistory" style="margin-right: 5px;margin-bottom: 5px" :src="url+item" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="医疗发票" prop="medicalInvoice">
              <div v-if="show3"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9" @click="getidCard3">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard3">
                <img v-for="(item,index) in form1.medicalInvoice"   :src="url+item" style="margin-right: 5px;margin-bottom: 5px" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="用药清单" prop="medications">
              <div v-if="show4"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9" @click="getidCard4">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard4">
                <img v-for="(item,index) in form1.medications" :src="url+item" style="margin-right: 5px;margin-bottom: 5px" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="其他图片" prop="other">
              <div v-if="show5"
                   style="width: 150px;height: 150px;line-height: 150px;text-align: center;border: 1px solid #d9d9d9"  @click="getidCard5">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
              <div v-else style="display: flex;flex-flow: wrap;align-items: center;" @click="getidCard5">
                <img v-for="(item,index) in form1.other" :src="url+item" style="margin-right: 5px;margin-bottom: 5px" width="130" height="100px">
              </div>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 上传身份证-->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="10"
        action
        :before-upload="beforeUploadForm"
        :auto-upload="false"
        :show-file-list="true"
        :http-request="handleUpdateForm"
        multiple
        :file-list="fileList"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open= false">取 消</el-button>
      </div>
    </el-dialog>
    <!--  上传住院小结-->
    <el-dialog :title="upload1.title" :visible.sync="upload1.open" width="400px" append-to-body>
      <el-upload
        ref="upload1"
        :limit="10"
        action
        :http-request="handleUpdateForm1"
        :before-upload="beforeUploadForm1"
        :auto-upload="false"
        :show-file-list="true"
        multiple
        :file-list="fileList1"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>

        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm1">确 定</el-button>
        <el-button @click="upload1.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!--  上传病例本-->
    <el-dialog :title="upload2.title" :visible.sync="upload2.open" width="400px" append-to-body>
      <el-upload
        ref="upload2"
        action
        :limit="10"
        :http-request="handleUpdateForm2"
        :before-upload="beforeUploadForm2"
        :auto-upload="false"
        :show-file-list="true"
        multiple
        :file-list="fileList2"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>

        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm2">确 定</el-button>
        <el-button @click="upload2.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload3.title" :visible.sync="upload3.open" width="400px" append-to-body>
      <el-upload
        ref="upload3"
        action
        :limit="10"
        :http-request="handleUpdateForm3"
        :before-upload="beforeUploadForm3"
        :auto-upload="false"
        :show-file-list="true"
        multiple
        :file-list="fileList3"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>

        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm3">确 定</el-button>
        <el-button @click="upload3.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload4.title" :visible.sync="upload4.open" width="400px" append-to-body>
      <el-upload
        ref="upload4"
        action
        :limit="10"
        :http-request="handleUpdateForm4"
        :before-upload="beforeUploadForm4"
        :auto-upload="false"
        :show-file-list="true"
        multiple
        :file-list="fileList4"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>

        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm4">确 定</el-button>
        <el-button @click="upload4.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload5.title" :visible.sync="upload5.open" width="400px" append-to-body>
      <el-upload
        ref="upload5"
        action
        :limit="10"
        :http-request="handleUpdateForm5"
        :before-upload="beforeUploadForm5"
        :auto-upload="false"
        :show-file-list="true"
        multiple
        :file-list="fileList5"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>

        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“jpg”或“png”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm5">确 定</el-button>
        <el-button @click="upload5.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRepordRecord, getRepordRecord, delRepordRecord, addRepordRecord, updateRepordRecord, exportRepordRecord ,listReportedAndData} from "@/api/insurance/repordRecord";
import {uploadTmage, uploadTmage1} from "@/api/base/template";
import {listIndustry} from "@/api/insurance/industry";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getPicture, updatePicture} from "@/api/insurance/picture";

export default {
  name: "RepordRecord",
  components: {
    Treeselect
  },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 报案表格数据
      repordRecordList: [],
      url:process.env.VUE_APP_BASE_API,//地址
      show: true,//判断上传图片显示隐藏
      show1: true,//判断上传图片显示隐藏
      show2: true,//判断上传图片显示隐藏
      show3: true,//判断上传图片显示隐藏
      show4: true,//判断上传图片显示隐藏
      show5: true,//判断上传图片显示隐藏
      fileList:[],
      fileList1:[],
      fileList2:[],
      fileList3:[],
      fileList4:[],
      fileList5:[],
      title1:'',
      open1:false,
      //上传身份证
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      //上传住院小结
      upload1: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      //上传病例本
      upload2: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      //上传医疗发票
      upload3: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      //上传用药清单
      upload4: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      //上传其他图片
      upload5: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        actualUnit: null,
        laborUnit: null,
        businessUnit: null,
        accidentTime: null,
        industryId: null,
        description: null,
        industryName: null,
        estimateMoney: null,
        statuses:['0','1']
      },
      // 表单参数
      form: {
        insureId:null,//保单id
        id: null,
        name: null,//姓名1
        actualUnit: null,//实际用工单位2
        laborUnit: null,//劳动合同单位3
        businessUnit: null,//业务来源单位4
        accidentTime: null,//事故发生时间5
        industryId: null,//工种6
        description: null,//事情经过7
        industryName: null,//工种名称8
        estimateMoney: null,//预估金额单位（元）9
        createTime: null,
        updateTime: null,
        remark:null,//备注
        idCardNo:null,//证件号码10
        // status: "0",
      },
      // 修改图片表单参数
      form1: {
        id: null,
        userId: null,
        medicalInvoice: [],
        medicalHistory: [],
        idCard: [],
        hospitalized: [],
        medications: [],
        other:[],
        createTime: null,
        updateTime: null,
        // status: "0"
      },
      // 修改图片表单校验
      rules1: {},
      // 职业分类树选项
      industryOptions: [],
      // 表单校验
      rules: {
      },

    };
  },

  created() {
    //获取投保id
    this.form.insureId=this.$store.state.user.infoUser.id
    console.log('insureInfo',this.form.insureId);
    this.getList();
    this.getDicts("report_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getTreeselect();
  },

  methods: {
    //查看详情
    handDetails(row){
      this.$router.push({
        path:'/business/reportAudit/details',
        query:{
          id:row.id
        }
      })
    },
    //资料上传
    handeImage(row){
      this.$router.push({
        path:'/business/repordRecord/repordImage',
        query:{
          id:row.id
        }
      })
    },
    getidCard(){
      this.upload.open=true;
      this.upload.title="上传身份证"
    },
    getidCard1(){
      this.upload1.open=true;
      this.upload1.title="上传住院小结"
    },
    getidCard2(){
      this.upload2.open=true;
      this.upload2.title="上传病历本"
    },
    getidCard3(){
      this.upload3.open=true;
      this.upload3.title="上传医疗发票"
    },
    getidCard4(){
      this.upload4.open=true;
      this.upload4.title="上传用药清单"
    },
    getidCard5(){
      this.upload5.open=true;
      this.upload5.title="上传其他图片"
    },
    /** 提交按钮 */
    submitForm1() {
      var form1={
        // createTime: this.form1.createTime,
        id:this.form1.id,
        idCard:JSON.stringify(this.form1.idCard),//身份证图片地址
        hospitalized:JSON.stringify(this.form1.hospitalized),//住院小结地址
        medicalHistory:JSON.stringify(this.form1.medicalHistory),//病例本图片地址
        medicalInvoice:JSON.stringify(this.form1.medicalInvoice),//医疗发票地址
        medications:JSON.stringify(this.form1.medications),//用药清单地址
        other:JSON.stringify(this.form1.other),//其他图片地址
        userId: this.form1.userId,
        // updateTime: this.form1.updateTime,
        // status: this.form1.status
      }
      console.log('form1',form1)
      this.$refs["form"].validate(valid => {
        if (valid) {
          // if (this.form.id != null) {
          console.log('sfdgdhfdh')
          updatePicture(form1).then(response => {
            this.msgSuccess("修改成功");
            this.open1 = false;
            this.getList();
          });
          // } else {
          //   addPicture(this.form).then(response => {
          //     this.msgSuccess("新增成功");
          //     this.open = false;
          //     this.getList();
          //   });
          // }
        }
      });
    },
    /** 转换职业分类数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children
      };
    },
    //选择工种名称
    selectDepart(e) {
      this.form.industryName = e.name
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      listIndustry().then(response => {
        this.industryOptions = [];
        const data = {id: 0, name: '顶级节点', children: []};
        data.children = this.handleTree(response.data, "id", "parentId");
        this.industryOptions.push(data);
        console.log('工种名称', response);
        console.log('industryOptions', this.industryOptions);
      });
    },
    //修改资料
    handleUpdateImage(row){
      console.log('用户资料',row)
      this.open1 = true;
      this.title1 = "修改用户图片";
      // this.reset();
      const id = row.id || this.ids
      this.form1.id=row.userPictureId;
      this.form1.userId=row.userId;
      this.form1.medicalInvoice=JSON.parse(row.userPicture.medicalInvoice);
        this.form1.medicalHistory=JSON.parse(row.userPicture.medicalHistory);
        this.form1.idCard=JSON.parse(row.userPicture.idCard);
        this.form1.hospitalized=JSON.parse(row.userPicture.hospitalized);
        this.form1.medications=JSON.parse(row.userPicture.medications);
        this.form1.other=JSON.parse(row.userPicture.other);
      console.log('用户资料form1', this.form1)
      // this.form1=row;
      if (this.form1.idCard.length!=0){
        this.show=false;
      }else {
        this.show=true;
      }
      if (this.form1.hospitalized.length!=0){
        this.show1=false;
      }else {
        this.show1=true;
      }
      if (this.form1.medicalHistory.length!=0){
        this.show2=false;
      }else {
        this.show2=true;
      }
      if (this.form1.medicalInvoice.length!=0){
        this.show3=false;
      }else {
        this.show3=true;
      }
      if (this.form1.medications.length!=0){
        this.show4=false;
      }else {
        this.show4=true;
      }
      if (this.form1.other.length!=0){
        this.show5=false;
      }else {
        this.show5=true;
      }
    },
    /** 查询报案列表 */
    getList() {
      console.log('insureId',this.form.insureId)
      this.loading = true;
      listReportedAndData(this.queryParams).then(response => {
        console.log('response',response)
        this.repordRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    //取消用户图片按钮
    cancel1(){
      this.open1 = false;
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        actualUnit: null,
        laborUnit: null,
        businessUnit: null,
        accidentTime: null,
        industryId: null,
        description: null,
        industryName: null,
        estimateMoney: null,
        createTime: null,
        updateTime: null,
        status: "0"
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      // // this.reset();
      // this.open = true;
      // this.title = "添加报案";
      this.$router.push({
        path:'/business/applicationFiling/applicationAdd'
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.form=row;
      this.open = true;
      this.title = "修改报案";
      // const id = row.id || this.ids
      // getRepordRecord(id).then(response => {
      //   this.form = response.data;
        console.log('form',this.form)
      //
      // });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRepordRecord(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRepordRecord(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除报案编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return delRepordRecord(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      var that=this;
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有报案数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        const loading = that.$loading({
          lock: true,
          text: '请耐心等待正在导出数据...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
       exportRepordRecord(queryParams).then(response=>{
         loading.close();
         that.$message({
           message: '导出数据成功!',
           type: 'success'
         });
         that.download(response.msg);
       });
      }).then(response => {

      })
    },
    // 上传身份证式显示
    beforeUploadForm(file) {
      console.log('file12', file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');

      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传身份证
    handleUpdateForm(param) {
      this.fileList.push(param.file);
    },
    submitFileForm(){
      this.$refs.upload.submit();
      let that = this;
      let formData = new FormData();
      this.fileList.forEach(v=>{
        formData.append('files',v);
      })

      uploadTmage1(formData).then(response => {
        this.fileList=[];
        // this.urlImage = response.url;
        this.form1.idCard = response.fileName
        // this.formData.seal = response.fileName;
        if (this.form1.idCard.length != 0) {
          this.show = false;
        } else {
          this.show = true;
        }
        this.upload.open=false
        console.log('res', response)

      })
    },
    // 上传住院小结格式显示
    beforeUploadForm1(file) {
      // console.log('file12',file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');

      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传住院小结
    handleUpdateForm1(param) {
      this.fileList1.push(param.file);
    },
    submitFileForm1(){
      this.$refs.upload1.submit();
      let that = this;
      let formData = new FormData();
      this.fileList1.forEach(v=>{
        formData.append('files',v);
      })
      uploadTmage1(formData).then(response => {
        this.fileList1=[];
        // this.urlImage = response.url;
        this.form1.hospitalized = response.fileName
        // this.formData.seal = response.fileName;
        if ( this.form1.hospitalized.length != 0) {
          this.show1 = false;
        } else {
          this.show1 = true;
        }
        this.upload1.open=false
        console.log('res', response)
      })
    },
    // 上传病例本显示
    beforeUploadForm2(file) {
      // console.log('file12',file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');

      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传病例本
    handleUpdateForm2(param) {
      this.fileList2.push(param.file);

    },
    submitFileForm2(){
      this.$refs.upload2.submit();
      let that = this;
      let formData = new FormData();
      this.fileList2.forEach(v=>{
        formData.append('files',v);
      })
      uploadTmage1(formData).then(response => {
        this.fileList2=[];
        // this.urlImage = response.url;
        this.form1.medicalHistory = response.fileName
        // this.formData.seal = response.fileName;
        if (this.form1.medicalHistory.length!= 0) {
          this.show2 = false;
        } else {
          this.show2 = true;
        }
        this.upload2.open=false
        console.log('res', response)
      })
    },
    // 上传医疗发票式显示
    beforeUploadForm3(file) {
      // console.log('file12',file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');

      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传医疗发票
    handleUpdateForm3(param) {
      this.fileList3.push(param.file);
    },
    submitFileForm3(){
      this.$refs.upload3.submit();
      let that = this;
      let formData = new FormData();
      this.fileList3.forEach(v=>{
        formData.append('files',v);
      })
      uploadTmage1(formData).then(response => {
        this.fileList3=[];
        // this.urlImage = response.url;
        this.form1.medicalInvoice = response.fileName
        if ( this.form1.medicalInvoice.length != 0) {
          this.show3 = false;
        } else {
          this.show3 = true;
        }
        this.upload3.open=false
        console.log('res', response)
      })
    },
    // 上传用药清单显示
    beforeUploadForm4(file) {
      // console.log('file12',file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传用药清单
    handleUpdateForm4(param) {
      this.fileList4.push(param.file);
    },
    submitFileForm4(){
      this.$refs.upload4.submit();
      let that = this;
      let formData = new FormData();
      this.fileList4.forEach(v=>{
        formData.append('files',v);
      })
      uploadTmage1(formData).then(response => {
        this.fileList4=[];
        // this.urlImage = response.url;
        this.form1.medications = response.fileName
        if (this.form1.medications.length!= 0) {
          this.show4 = false;
        } else {
          this.show4 = true;
        }
        this.upload4.open=false
        console.log('res', response)
      })
    },
    // 上传其他图片显示
    beforeUploadForm5(file) {
      // console.log('file12',file)
      const isPng = file.type === 'image/png' || 'image/jpg' || 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传签章只能是png/jpg/jpeg格式!');

      }
      if (!isLt2M) {
        this.$message.error('上传签章大小不能超过2MB!');
      }
      return isPng && isLt2M;
    },
    //上传其他图片
    handleUpdateForm5(param) {
      this.fileList5.push(param.file);
    },
    submitFileForm5(){
      this.$refs.upload5.submit();
      let that = this;
      let formData = new FormData();
      this.fileList5.forEach(v=>{
        formData.append('files',v);
      })
      uploadTmage1(formData).then(response => {
        this.fileList5=[];
        // this.urlImage = response.url;
        this.form1.other = response.fileName
        if (  this.form1.other.length!= 0) {
          this.show5 = false;
        } else {
          this.show5 = true;
        }
        this.upload5.open=false
        console.log('res', response)
      })
    }
  }
};
</script>

